<?
include("../../common/header.html");
include("../../common/left.html");
include("../../common/page.php");
$currentPage=$_REQUEST["currentPage"]?$_REQUEST["currentPage"]:1;
$pageSize=$_REQUEST['pageSize']?$_REQUEST["pageSize"]:10;
$offset=($currentPage-1)*$pageSize;
$where="where  fid=".$_SESSION['sid'];
$btime=$_REQUEST['btime'];
$etime=$_REQUEST['etime'];
if($days=abs($_REQUEST['days'])){
    $btime=time()-3600*24*$days;
    $btime=date("Y-m-d",$btime);
    $etime=date("Y-m-d");
}
if($btime){
    $where.=" and apply_time>='".$btime." 00:00:00'";
}
if($etime){
    $where.=" and apply_time<='".$etime." 23:59:59'";
}
$str="select c.*,d.dname,d.fee_bank,c.fee_bank_once from pft_wd_cash c left join pft_member d on d.id=c.fid $where order by apply_time desc limit $offset,$pageSize";

$GLOBALS['le']->query($str);
$r=array();
while($row=$GLOBALS['le']->fetch_assoc()){
    $r[]=$row;
}
$wd_statusT=array(0=>"<em class='orange'>处理中</em>",
    1=>"<em class='green'>已成功</em>",
    2=>"<em class='red'>已拒绝</em>",
    3=>"<em class='red'>已取消</em>");
?>
    <script src="js/Calendar.js" type="text/javascript"></script>
    <link href="css/page.css" rel="stylesheet" type="text/css" />
    <style>
        .orange{color:orange;}
        .green{color:green;}
        .red{color:red;}
        #right .notice{ margin-bottom: 10px; margin-top: 10px; padding: 20px; border:1px solid #ccc}
        #right .notice span{margin-right:20px}
        #right .time{ width:100px; border:1px solid #7F9DB9; height:18px; background:url("images/rili.png") no-repeat right center #FFFFFF;}
        .apply table{ width:100%; margin-bottom:20px;}
        .apply th{ background: none repeat scroll 0 0 #F3FAFF;border-bottom: 1px solid #DDEEFB;border-top: 1px solid #DDEEFB;height: 27px;line-height: 27px;text-align: center;}
        .apply td{ border-bottom: 1px dashed #DDDDDD;line-height: 20px;padding: 10px 0;text-align: center;}
        .butbg{background:url(../images/search.png) no-repeat 0 0; cursor: pointer;height: 30px;width: 80px;border:none;}
    </style>
    <!--提现记录-->

    <div id="right" class="r_content"><!--BEGIN OF RIGHT-->
        <h3 class="mc_title">
            <span class="mctit_1"><span class="mctit_2">账户提现</span></span>
        </h3>
        <div class="notice">
            <form action="">
                <span>申请日期：<input type="text" class="time" onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" value="<?=$btime?>" name="btime" /> 至 <input type="text" class="time" name="etime" onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" value="<?=$etime?>"/></span><i> </i>
				<span>
					<a href="?days=7" class="monrea <?=($days==7)?"cuream":""?>">最近7天</a>
					<a href="?days=30" class="monrea <?=($days==30)?"cuream":""?>">最近30天</a></span>
                <span><input type="submit" value=" " class="butbg" /></span>
            </form>
        </div>

        <div class="apply">
            <table>
                <tr class="header">
                    <th class="col5">申请日期</th>
                    <th class="col4">提现金额</th>
                    <th class="col2">手续费</th>
                    <th class="col3">应收金额</th>
                    <th class="col1">收款账号</th>
                    <th class="col6">操作员</th>
                    <th class="col7">状态</th>
                    <th>操作</th>
                </tr>
                <?foreach($r as $row){?>
                    <?  $pay_money=$row['wd_money']*$row['fee_bank_once']/100000;?>
                    <tr class="<?=(++$i%2==0)?"odd":"even"?>">
                        <td class="col5">
						<span title="<?=$row['apply_time']?>">
							<?=substr($row['apply_time'],0,10)?>
						</span>
                        </td>
                        <td class="col4"><?=$row['wd_money']/100?></td>
                        <td class="col2"><?=($pay_money<1&&$pay_money>0)? 1:round($pay_money); ?></td>
                        <td class="col3"><?=($pay_money<1&&$pay_money>0)? ($row['wd_money']/100-1):($row['wd_money']/100-round($pay_money));?></td>
                        <td class="col1"><?=$row['wd_name']?> <?=$row['bank_name']?></br><?=substr_replace($row['bank_accuont'],"***",4,11);?></td>
                        <td class="col6"><?=$row['dname']?></td>
                        <td class="col7"><?=$wd_statusT[$row['wd_status']]?></td>
                        <td><?if($row['wd_status']=='0'){?><a class="cancel" href="../../call/handle.php?from=withdraw_cancel&id=<?=$row['id']?>">取消申请</a><?}else{?>已处理<?}?></td>
                    </tr>
                <?}?>
                <?if(count($r)==0){?>
                    <tr><td style="text-align:left; padding-left:50px;" colspan='9'>无处理中提现申请</td></tr>
                <?}?>
            </table>
            <?if(count($r)>0) page(count($r),$currentPage,$pageSize);?>
        </div>
    </div><!--EOF RIGHT-->
    <!--提现记录END-->
    <script>
        $(".cancel").click(function(){
            if(confirm("确定要取消提现申请?")){
                $.ajax({
                    "url":$(this).attr("href"),
                    "dataType":"json",
                    "success":function(data){
                        if(data.outcome==1){
                            alert("取消成功");
                            window.location=window.location.href;
                        }else{
                            alert("取消失败");
                        }
                    }
                })
            }
            return false;
        })
    </script>
<?include("../../common/footer.html");?>